package com.remeberword;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.remeberword.db.Word;

import java.util.List;

/**
 * Created by arch on 2018/3/13.
 */

public class ManageWordAdapter extends WordAdapter {

    private WordManageActivity wordManageActivity;

    public ManageWordAdapter(List<Word> wordList, WordManageActivity wordManageActivity) {
        super(wordList);
        this.wordManageActivity = wordManageActivity;
    }

    static class ViewHolder extends WordAdapter.ViewHolder {
        private View wordView;

        public ViewHolder(View view) {
            super(view);
            wordView = view;
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.manage_word_item, parent, false);
        final ViewHolder holder = new ViewHolder(view);
        holder.wordView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int position = holder.getAdapterPosition();
                Word word = wordList.get(position);
                wordManageActivity.loadDetailActivity(word);
            }
        });
        return holder;
    }
}
